<template>
  <div>
    <!--面包屑导航区域-->
    <el-breadcrumb separator-class="el-icon-arrow-right">
      <el-breadcrumb-item :to="{ path: '/home' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item>订单管理</el-breadcrumb-item>
      <el-breadcrumb-item>订单列表</el-breadcrumb-item>
    </el-breadcrumb>
    <!--卡片视图区域-->
    <el-card class="box-card">
      <!--搜索区域-->
      <el-row :gutter="18">
        <el-col :span="8">
          <el-input placeholder="请输入内容" class="input-with-select" v-model="queryparams.query"  clearable @clear="getOrderList">
            <el-button slot="append" icon="el-icon-search" @click="getOrderList"></el-button>
          </el-input>
        </el-col>
      </el-row>
      <!--用户列表区域-->
      <el-table
        class="ordertable"
        :data="orderList.goods"
        border
        style="width: 100%" :stripe="true">
        <el-table-column   type="index"></el-table-column>
        <el-table-column  prop="order_number"  label="订单编号"   width="180"></el-table-column>
        <el-table-column  prop="order_price" label="订单价格"></el-table-column>
        <el-table-column  prop="pay_status"   label=是否付款>
          <template slot-scope="scope">
            <el-tag v-if="scope.row.pay_status==1">已付款</el-tag>
            <el-tag v-else>未付款</el-tag>
          </template>
        </el-table-column>
        <el-table-column  prop="is_send"     label="是否发货"></el-table-column>
        <el-table-column   label="下单时间">
          <template slot-scope="scope">
            {{scope.row.create_time | dataFormat}}
          </template>
        </el-table-column>
        <el-table-column  label="操作">
          <template slot-scope="scope">
            <el-button type="primary" icon="el-icon-edit"   @click="handleEdit(scope.row.id)"></el-button>
            <el-button type="danger" icon="el-icon-s-tools"   @click="handleconfig(scope.row.id)"></el-button>
          </template>
        </el-table-column>
      </el-table>
      <!--分页区域-->
      <el-pagination
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page="queryparams.pagenum"
        :page-sizes="[1, 2, 5, 7]"
        :page-size="queryparams.pagesize"
        layout="total, sizes, prev, pager, next, jumper"
        :total="total">
      </el-pagination>
    </el-card>
<!--弹出窗口-->
    <el-dialog
      title="修改地址"
      :visible.sync="dialogVisible"
      width="50%">
      <el-form :model="addressForm" :rules="addressFormRules" ref="addressFormRef" >
        <el-form-item label="省市区/县" prop="address1">
         <el-cascader :options="CityData" v-model="addressForm.address1"></el-cascader>
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
    <el-button @click="dialogVisible = false">取 消</el-button>
    <el-button type="primary" @click="dialogVisible = false">确 定</el-button>
  </span>
    </el-dialog>
  </div>
</template>

<script>
  import CityData from './citydata.js'

  export default {
    name: 'order',
    data:function () {
        return {
          queryparams:{
            query:'',
            pagenum:  1,
            pagesize: 5
            },
          orderList:[],
          total:0,
          dialogVisible:false,
          addressForm:{
            address1:[]
          },
          addressFormRules:{
            address1:[{
              required:true,message:'请选择省市区县',trigger:'blur'
            }]
          },
          CityData
        }
    },
    methods:{
      handleEdit(){},
      handleconfig(){
        this.dialogVisible=true;
      },
      handleSizeChange(newsize){
        this.queryparams.pagesize=newsize;
        this.getOrderList();
      },
      handleCurrentChange(pagenum){
        this.queryparams.pagenum=pagenum;
        this.getOrderList();
      },
      async getOrderList(){
        console.log(this.queryparams);
        var data=  await this.$axios.get('orders',{params:this.queryparams})
        var res=data.data;
        if(res.meta.status!=200){
          return this.$message.error("获取订单列表失败!");
        }
        this.orderList=res.data;
        this.total=res.data.total;
        console.log("this.orderlist=",this.orderList);
      }
    },
    created () {
      this.getOrderList();
    }

  }
</script>

<style scoped>
.ordertable{
  margin-top: 15px;
}
</style>
